﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no" />
    <title>客户信息</title>
     <script src="../JS/layer/layer.m.js"></script>
     <link href="../Frozenui1.3/css/frozen.css" rel="stylesheet" />
    <style type="text/css">
        .ui-select {
            border: none;
            border: 0;
            background-color: #fff;
            appearance: none;
            -moz-appearance: none; /* Firefox */
            -webkit-appearance: none; /* Safari 和 Chrome */
        }
    </style>
</head>
<body ms-controller="khmodel">
    <div id="content">
        <div class="ui-footer ui-footer-stable ui-btn-group ui-border-t" >
            <button class="ui-btn-lg ui-btn-primary" ms-click="savedata()">
                新增客户
            </button>
        </div>
        <section class="ui-container" >
            <div class="ui-form ui-border-t">
                <div class="ui-form-item ui-border-b">
                    <label>
                        客户类别
                    </label>
                    <div class="ui-select ui-border-b">
                        <select ms-duplex="ctData.KHLeiBie"></select>
                    </div>
                </div>
                <div class="ui-form-item ui-border-b">
                    <label>
                        客户姓名
                    </label>
                    <input type="text" placeholder="请输入客户姓名" ms-duplex="ctData.KHName" />
                </div>
                <div class="ui-form-item ui-border-b ">
                    <label>
                        客户性别
                    </label>
                    <div class="ui-select ui-border-b">
                        <select ms-duplex="ctData.KHXinBie">
                            <option value="女士">女士</option>
                            <option value="先生">先生</option>
                        </select>
                    </div>
                </div>
                <div class="ui-form-item ui-border-b">
                    <label>
                        手机号
                    </label>
                    <input type="text" placeholder="请输入手机号" ms-duplex="ctData.KHPhone" />

                </div>
                <div class="ui-form-item ui-border-b">
                    <label>
                        所属单位
                    </label>
                    <input type="text" placeholder="请输入所属单位" ms-duplex="ctData.KHDW" />

                </div>
                <div class="ui-form-item ui-border-b">
                    <label>
                        职务
                    </label>
                    <input type="text" placeholder="请输入职务" ms-duplex="ctData.KHZhiWu" />

                </div>
                <div class="ui-form-item ui-border-b">
                    <label>
                        联系地址
                    </label>
                    <input type="text" placeholder="请输入联系地址" ms-duplex="ctData.KHAdress" />

                </div>
                <div class="ui-form-item ui-border-b" style="height:auto">
                    <label>
                        负责人
                    </label>
                    <div class="ui-txt-muted ui-whitespace" style="padding-left: 95px;text-align:justify" id="kh_fzry" ms-click="selperson()">请选择客户负责人员</div>
                    <!--<input type="text" placeholder="请输入客户负责人员" id="kh_fzry" ms-click="selperson()" readonly="readonly" />-->

                </div>

            </div>

        </section>
    </div>
    <iframe id="iframep" src="UI_PERSON.html" style="display:none"></iframe>

    <script src="../JS/zepto.min.js"></script>
    <script src="../Frozenui1.3/js/frozen.js"></script>
    <script src="../JS/avalon.min.js"></script>

    <script src="../JS/MobileCom.js?v=1.1"></script>
    <script>
        //MobileCom.delCookie("szhlcode");
        //if (MobileCom.getCookie("szhlcode") == null) {
        //    MobileCom.setCookie("szhlcode", "1a3fea9a-5636-4930-a973-9424e0be113f", 7);
        //}

        var height = 0;
        var model = avalon.define({
            $id: "khmodel",
            ctData: { "KHLeiBie": "", "KHName": "", "KHXinBie": "女士", "KHPhone": "", "KHDW": "", "KHZhiWu": "", "KHAdress": "", "KHFXRS": "" },
            cpData: [],
            savedata: function () {
                var lg = $.loading({
                    content: '保存中...',
                })
                $.post("/API/WXAPI.ashx?Action=ADDKHGL&r=" + Math.random(), { "P1": JSON.stringify(model.ctData.$model) }, function (data) {
                    lg.hide();
                    var data = $.parseJSON(data);
                    if (data.ErrorMsg == "") {
                        $("button").hide();
                        var el = $.tips({
                            content: "保存成功！！",
                            stayTime: 2000,
                            type: "success"
                        })
                        el.on("tips:hide", function () {
                            window.location.reload();
                        })
                    }
                    else {
                        $.tips({
                            content: "保存失败，原因：" + data.ErrorMsg,
                            stayTime: 2000,
                            type: "warn"
                        })
                    }
                })
            },
            repshow: function () {
                $(this).parent().siblings().removeClass("active");
                $(this).parent().addClass("active");
            },
            selperson: function () {
                $("#content").hide();
                $("#iframep").show();

                var cheight = height;
                var cwidth = document.documentElement.clientWidth-5;

                $("#iframep").css("height", cheight);
                $("#iframep").css("width", cwidth);

            }

        });

        function goback() {
            $("#content").show();
            $("#iframep").hide();
        }
        function goconfirm(json) {
            if (json != null) {
                $("#kh_fzry").removeClass("ui-txt-muted");
                $("#kh_fzry").html(json.vuser);
                model.ctData.KHFXRS = json.vusername;
            }
            else {
                $("#kh_fzry").addClass("ui-txt-muted");
                $("#kh_fzry").html('请选择客户负责人员');
                model.ctData.KHFXRS = '';
            }

            $("#content").show();
            $("#iframep").hide();
        }

        avalon.ready(function () {
            height = document.documentElement.clientHeight - 11;
            var lg = $.loading({
                content: '加载中...'
            })
            $.post("/API/WXAPI.ashx?Action=GETCOLUMNLIST&r=" + Math.random(), { "P1": "8" }, function (data) {
                lg.hide();
                var data = $.parseJSON(data);
                if (data.ErrorMsg == "") {
                    $("select").eq(0).empty();
                    for (var i = 0; i < data.Result.length; i++) {
                        $("select").eq(0).append('<option value="' + data.Result[i].TypeNO + '">' + data.Result[i].TypeNO + '</option>');
                        if (i == 0) {
                            model.ctData.KHLeiBie = data.Result[i].TypeNO;
                        }
                    }
                }
                else {
                    $.tips({
                        content: "客户类别加载失败，原因：" + data.ErrorMsg,
                        stayTime: 2000,
                        type: "warn"
                    })
                }
            })
            $("#iframep").attr("src", "UI_PERSON.html?r=" + Math.random());
        })
    </script>
</body>

</html>
